package com.freak.freakmusic.model.homepage.tab

import android.os.Bundle
import android.view.View
import com.freak.freakmusic.R
import com.freak.freakmusic.base.BaseAbstractMvpFragment
import com.freak.freakmusic.utils.ToastUtil
import com.freak.kotlinhttpmanager.kotlinhttpmanager.log.LogUtil
import com.scwang.smartrefresh.layout.api.RefreshLayout

/**
 * 标签分类fragment
 */
class TabFragment() :
    BaseAbstractMvpFragment<TabContract.View, TabContract.Presenter>(), TabContract.View {
    private var mRefreshLayout: RefreshLayout? = null
    private var type: String? = null
    private var bundle: Bundle? = null


    override val layoutId: Int
        get() = R.layout.fragment_tab

    override fun createPresenter(): TabContract.Presenter {
        return TabPresenter()
    }

    override fun initEventAndData(view: View) {

    }

    override fun initLazyData() {
        bundle = arguments
        if (bundle == null) {
            mActivity.finish()
            return
        }
        type = bundle?.getString("type")

    }

    override fun showLoading() {

    }

    override fun showToast(toast: String) {
        ToastUtil.shortShow(toast)
    }

    fun onRefresh(refreshLayout: RefreshLayout) {
        LogUtil.e("更新  MarketingActivityFragment")
        mRefreshLayout = refreshLayout
        refreshLayout.layout.postDelayed({
            refreshLayout.finishRefresh()
            refreshLayout.resetNoMoreData()//setNoMoreData(false);
        }, 2000)
    }
}